import Vue from 'vue';
import VueRouter from 'vue-router';
import Router from 'vue-router';
import Layout from '../layout/index';
import store from '../store'
Vue.use(VueRouter);

const routes = [{
        path: '/',
        name: 'home',
        component: () => import('../views/home')
    },
    {
        path: '/TRAFFIC',
        name: 'TRAFFIC',
        component: () => import('../views/TRAFFIC/index')
    },
    {
        path: '/LIFT',
        name: 'LIFT',
        component: () => import('../views/LIFT/index')
    },
    {
        path: '/BRIDGE',
        name: 'BRIDGE',
        component: () => import('../views/BRIDGE/index')
    },
    {
        path: '/GREENMARK',
        name: 'GREENMARK',
        component: () => import('../views/GREENMARK/index')
    },
    {
        path: '/FLOOD',
        name: 'FLOOD',
        component: () => import('../views/FLOOD/index')
    },
    {
        path: '/CAMPUS',
        name: 'CAMPUS',
        component: () => import('../views/CAMPUS/index')
    },
    {
        path: '/AIRPORT',
        name: 'AIRPORT',
        component: () => import('../views/AIRPORT/index')
    },
    {
        path: '/window_traffic',
        name: 'window_traffic',
        component: () => import('../views/window/traffic')
    },
    {
        path: '/window_bridge',
        name: 'window_bridge',
        component: () => import('../views/window/bridge')
    },
    {
        path: '/window_campus',
        name: 'window_campus',
        component: () => import('../views/window/campus')
    },
    {
        path: '/window_greenmark',
        name: 'window_greenmark',
        component: () => import('../views/window/greenmark')
    },
    {
        path: '/window_flood',
        name: 'window_flood',
        component: () => import('../views/window/flood')
    },
    {
        path: '/window_lift',
        name: 'window_lift',
        component: () => import('../views/window/lift')
    },

]

const router = new Router({
    routes
})

router.beforeEach((to, from, next) => {
    //console.log(to.name, from.name);
    if (to.path === '/') {
        store.commit('app/CHANGE_HOME', false)
    } else {
        store.commit('app/CHANGE_HOME', true)
    }
    next()
})

export default router;